#include "matrix.h"

Matrix2::Matrix2(const Matrix2& other)
    : m11_(other.m11_), m12_(other.m12_), m21_(other.m21_), m22_(other.m22_) {}

Matrix2::Matrix2(const Vector2D& v1, const Vector2D& v2)
    : m11_(v1.X()), m12_(v1.Y()), m21_(v2.X()), m22_(v2.Y()) {}

Matrix2::Matrix2(const ZNumber& m11, const ZNumber& m12, const ZNumber& m21,
                 const ZNumber& m22)
    : m11_(m11), m12_(m12), m21_(m21), m22_(m22) {}

void Matrix2::operator=(const Matrix2& other) {
  m11_ = other.m11_;
  m12_ = other.m12_;
  m21_ = other.m21_;
  m22_ = other.m22_;
}

Matrix2 Matrix2::operator+(const Matrix2& other) const {
  return Matrix2(m11_ + other.m11_, m12_ + other.m12_, m21_ + other.m21_,
                 m22_ + other.m22_);
}

Matrix2 Matrix2::operator-(const Matrix2& other) const {
  return Matrix2(m11_ - other.m11_, m12_ - other.m12_, m21_ - other.m21_,
                 m22_ - other.m22_);
}

Matrix2 Matrix2::operator*(const ZNumber& other) const {
  return Matrix2(m11_ * other, m12_ * other, m21_ * other, m22_ * other);
}

bool Matrix2::operator==(const Matrix2& other) const {
  return m11_ == other.m11_ && m12_ == other.m12_ && m21_ == other.m21_ &&
         m22_ == other.m22_;
}

Matrix2 Matrix2::operator*(const Matrix2& other) const {
  Matrix2 res;
  res.m11_ = m11_ * other.m11_ + m12_ * other.m21_;
  res.m12_ = m11_ * other.m12_ + m12_ * other.m22_;
  res.m21_ = m21_ * other.m11_ + m22_ * other.m21_;
  res.m22_ = m21_ * other.m12_ + m22_ * other.m22_;
  return res;
}

Matrix2 Matrix2::Transposition() const {
  Matrix2 res;
  res.m11_ = m11_;
  res.m12_ = m21_;
  res.m21_ = m12_;
  res.m22_ = m22_;
  return res;
}